</html>
{include file="public/header" /}
<link rel="stylesheet" href="/static/index/trade/css/index.css">
<style>
    .buyout{
        position: fixed;
        line-height: 45px;
        text-align: center;
        color: var(--cl);
        font-size: 15px;
        bottom: 15px;
        width: 80%;
        left: 10%;
        height: 45px;
        border-radius: 20px;
        background: linear-gradient(to right ,rgb(254,129,1), rgb(235,29,35));
    }
    .buybg{
        background: var(--cc) !important;
    }
    body{
        padding-top: 0px !important;
    }
    .hmoney{
        width: 100%;
        text-align: center;
        font-size: 0.945rem;
        margin-top: 0.8rem;
    }
    .layui-layer-dialog{
        top:40% !important;
    }
    .layui-layer-iframe{
        top:0px !important;
    }
</style>
<body>
<ul class="pro-list-nav-top">
    <li data-type="1" class="{if $Request.param.type == 1 ||  !$Request.param.type}active{/if}">
        <div>买单</div>
        <p></p>
    </li>
    <li data-type="2" class="{if $Request.param.type == 2}active{/if}">
        <div>卖单</div>
        <p></p>
    </li>
</ul>
<div class="hmoney">当前交易价格：{$money}元</div>
<div class="list tpl_list" style="margin-top: 0.8rem;padding-bottom:80px;"></div>

</body>
{include file="public/footer"/}

{include file="public/menu" select="5" /}
<script id="template" type="text/html">
    {{# for(var i = 0; i < d.data.length; i++) { }}
    <div class="item">
        <div class="t flex-layout">
            <div>交易数量：{{d.data[i].n_count}}</div>
            <div>{{d.data[i].type == 1?"买家":"卖家"}}：{{d.data[i].user.nickname}}{{d.data[i].user.mobile?'-'+d.data[i].user.mobile:''}}</div>
        </div>
        <div class="b flex-layout">
            <div class="time">发布时间：{{d.data[i].create_time}}</div>
        </div>
        <div class="b flex-layout">
            <div class="time">单价：{{d.data[i].price}}</div>
            <div class="time">总价：{{d.data[i].money}}</div>
            <div class="{{d.data[i].is_full == 1 ?'':'btn btn-buy'}}" data-type="{{d.data[i].type}}" data-id="{{d.data[i].id}}">{{d.data[i].is_full == 1 ?'':(d.data[i].type == 1?"卖出":"买入")}}</div>
        </div>
    </div>
    {{# } }}
</script>
<script>
    $(function () {
        getFlow('{$Request.param.type?:1}',"{:url('deal/getList')}");
    });
    $('.pro-list-nav-top li').click(function () {
        $(".tpl_list").empty();
        $(this).addClass('active').siblings().removeClass('active');
        getFlow($(this).attr('data-type'),"{:url('deal/getList')}");
    });
    $('.tpl_list').on('click', '.btn-buy', function () {
        var id = $(this).attr('data-id'),
        type = $(this).attr('data-type'),
        ind=layer.confirm('确定要'+(type==1?'卖出':'买入')+'吗？', {title: '请确认'}, function () {
            buyout('{$open}',(type==1?'卖出':'买入')+'交易','{:url("deal/index")}?id='+id+'&type='+type);
            layer.close(ind);
        });
    });
    $('.bgc').on('click', '.buyout', function () {
        buyout('{$open}','发布交易', '{:url("deal/index")}');
    });
      
    window.receiveValue = function(value) {
        if(value!=''){
            $(".tpl_list").empty();
            layer.closeAll();
            setTimeout(function () {    
                getFlow(value.type,"{:url('deal/getList')}");
            },300)
        }
    }
    function buyout(open,title,url){
        if(open==1){
            layer.msg('请完善收款方式！');
            return false;
        }else{
            layer.open({
                type: 2,
                title: title,
                shadeClose: true, // 点击遮罩关闭弹窗
                area: ['100%', '100%'],
                content: url
            });
        }
    }
</script>
</html>